package org.eclipseuseradmin.internal.ui.wizards;

import javax.security.auth.callback.ConfirmationCallback;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.TextOutputCallback;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IWorkbench;

public class LoginWizard extends Wizard {

	private IWorkbench workbench;

	private IStructuredSelection selection;

	private ConfirmationCallback confirmationCallback;
	
	private TextOutputCallback messageCallback;
	
	private NameCallback nameCallback;
	
	private PasswordCallback passwordCallback;

	private LoginWizardPage mainPage;

	public LoginWizard() {

		setForcePreviousAndNextButtons(true);
	}

	public void init(ConfirmationCallback confirmationCallback,
			TextOutputCallback messageCallback, NameCallback nameCallback,
			PasswordCallback passwordCallback) {

		this.confirmationCallback = confirmationCallback;
		this.messageCallback = messageCallback;
		this.nameCallback = nameCallback;
		this.passwordCallback = passwordCallback;
	}

	@Override
	public void addPages() {

		mainPage = new LoginWizardPage();
		mainPage.setErrorMessage(messageCallback.getMessage());
		addPage(mainPage);
	}

	@Override
	public boolean performFinish() {

		confirmationCallback.setSelectedIndex(ConfirmationCallback.OK);
		return true;
	}
	

	@Override
	public boolean performCancel() {
		
		confirmationCallback.setSelectedIndex(ConfirmationCallback.CANCEL);
		return true;
	}

	public IWorkbench getWorkbench() {
		return workbench;
	}

	public IStructuredSelection getSelection() {
		return selection;
	}

	public NameCallback getNameCallback() {
		return nameCallback;
	}

	public PasswordCallback getPasswordCallback() {
		return passwordCallback;
	}

	public ConfirmationCallback getConfirmationCallback() {
		return confirmationCallback;
	}


}
